# Maintainer: Frederic Wang <fred.wang@free.fr>

_realname=pyasn1-modules
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.2.1
pkgrel=1
pkgdesc='A collection of ASN.1-based protocols modules (mingw-w64)'
url='https://sourceforge.net/projects/pyasn1/'
license=('BSD')
arch=('any')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python2-pyasn1"
             "${MINGW_PACKAGE_PREFIX}-python3-pyasn1")
source=(${_realname}-${pkgver}.tar.gz::"https://pypi.io/packages/source/p/pyasn1-modules/${_realname}-${pkgver}.tar.gz")
sha256sums=('af00ea8f2022b6287dc375b2c70f31ab5af83989fc6fe9eacd4976ce26cd7ccc')

prepare() {
  cd ${srcdir}
  cp -r ${_realname}-${pkgver} build-python2
  cp -r ${_realname}-${pkgver} build-python3
}

package_python3-pyasn1-modules() {
  cd ${srcdir}/build-python3
  ${MINGW_PREFIX}/bin/python3 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-pyasn1-modules() {
  cd ${srcdir}/build-python2
  ${MINGW_PREFIX}/bin/python2 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-pyasn1-modules() {
  package_python2-pyasn1-modules
}

package_mingw-w64-i686-python3-pyasn1-modules() {
  package_python3-pyasn1-modules
}

package_mingw-w64-x86_64-python2-pyasn1-modules() {
  package_python2-pyasn1-modules
}

package_mingw-w64-x86_64-python3-pyasn1-modules() {
  package_python3-pyasn1-modules
}
